{extend name="public:_base" /}

{block name="css"}
{CSS href="__STATIC__/w/admin_base.css" /}
{CSS href="__STATIC__/w/layui.css" /}
{CSS href="__STATIC__/w/divtable.css" /}
{/block}

{block name="js"}
{js href='__STATIC__/w/jquery1110min.js' /}
{js href='__STATIC__/w/layui.js' /}
{/block}

{block name="main"}

<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 关键字回复
    <a class="btn radius btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>

<div class="layui-form-cont">
    <a class="layui-btn radius layui-btn-normal" href="{:url('addkeyword')}">
        <i class="Hui-iconfont">&#xe600;</i> 增加关键词
    </a>
    <div class="layui-tab layui-tab-nav">
        <div class="layui-tab-left">
            <a class="layui-btn radius layui-btn-normal" href="{:url('addkeyword')}">
                <i class="Hui-iconfont">&#xe600;</i> 增加关键词
            </a>
        </div>

        <div class="layui-tab-right">
            <ul class="layui-tab-title">
                <li {eq name="action_name" value="autoreply"}class="layui-this"{/eq}>
                    <a href="{:url('autoreply')}">关键词回复</a>
                </li>
                <li {eq name="action_name" value="special"}class="layui-this"{/eq}>
                    <a href="{:url('special')}">特殊消息/事件</a>
                </li>
                <!--<li {eq name="action_name" value="autoreply"}class="layui-this"{/eq}>事件回复</li>-->
                <!--<li {eq name="action_name" value="autoreply"}class="layui-this"{/eq}>未识别回复</li>-->
            </ul>
        </div>
    </div>

    <div class="clear"></div>

    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

        <ul class="layui-tab-title">
            <li {eq name="type" value="text"}class="layui-this"{/eq} ><a href="{:url('autoReply',['type'=>'text'])}">回复文字</a></li>
            <li {eq name="type" value="news"}class="layui-this"{/eq}><a href="{:url('autoReply',['type'=>'news'])}">回复图文</a></li>
            <!--<li {eq name="type" value="addon"}class="layui-this"{/eq}><a href="{:url('autoReply',['type'=>'addon'])}">回复应用</a></li>-->
            <li {eq name="type" value="voice"}class="layui-this"{/eq}><a href="{:url('autoReply',['type'=>'voice'])}">回复语音</a></li>
            <li {eq name="type" value="image"}class="layui-this"{/eq}><a href="{:url('autoReply',['type'=>'image'])}">回复图片</a></li>
            <li {eq name="type" value="video"}class="layui-this"{/eq}><a href="{:url('autoReply',['type'=>'video'])}">回复视频</a></li>
            <li {eq name="type" value="music"}class="layui-this"{/eq}><a href="{:url('autoReply',['type'=>'music'])}">回复音乐</a></li>
        </ul>

        <div class="layui-tab-content layui-new-table">

            {switch name="type"}
            {case value="text"}
            <table class="layui-table" lay-skin="line">
                <colgroup>
                    <col width="120">
                    <col >
                    <col width="100" >
                    <col width="150">
                </colgroup>
                <thead>
                <tr>
                    <th>关键词</th>
                    <th>回复内容</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.keyword}</td>
                    <td>{$vo.content}</td>
                    <td>{if condition="$vo.status=='1'"}使用中{else/}已停用{/if}</td>
                    <td>
                        <div class="">
                            <a class="rha-bt-a" href="javascript:;" onclick="editReply('{$vo.id}')">修改</a>
                            {if condition="$vo.status=='1'"}
                            <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','0')">停用</a>
                            {else/}
                            <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','1')">开启</a>
                            {/if}
                            <a class="rha-bt-a" href="javascript:;" onclick="delReply('{$vo.id}')">删除</a>
                        </div>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {case value="news"}
            <table class="layui-table" lay-skin="line">
                <col width="120">
                <col width="200">
                <col width="150">
                <col width="">
                <col width="100" >
                <col width="150">
                <thead>
                <tr>
                    <th>关键词</th>
                    <th>标题</th>
                    <th>封面图</th>
                    <th>图文描述</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.keyword}</td>
                    <td>{$vo.title}</td>
                    <td>
                        <div  style="padding: 5px; border: #e6e6e6 solid 1px; width:160px; float: left; ">
                            <img class="form_logo" src="__PUBLIC__/uploads/addkey/{$vo.url}" style="max-width: none" width="160" height="100">
                        </div>
                    </td>
                    <td>{$vo.content}</td>
                    <td>{if condition="$vo.status=='1'"}使用中{else/}已停用{/if}</td>
                    <td>
                        <div class="">
                            <a class="rha-bt-a" href="javascript:;" onclick="editReply('{$vo.id}')">修改</a>
                            {if condition="$vo.status=='1'"}
                            <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','0')">停用</a>
                            {else/}
                            <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','1')">开启</a>
                            {/if}
                            <a class="rha-bt-a" href="javascript:;" onclick="delReply('{$vo.id}')">删除</a>

                        </div>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {case value="addon"}
            <table class="layui-table" lay-skin="line">
                <col width="120">
                <col width="200">
                <col width="" >
                <col width="100">
                <col width="150">
                <thead>
                <tr>
                    <th>关键词</th>
                    <th>应用名称</th>
                    <th>应用简介</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.keyword}</td>
                    <td>
                        <div  style=" float: left; ">
                            <img class="form_logo" src="__PUBLIC__/uploads/addkey/{$vo.logo}" width="30" height="30">{$vo.name}
                        </div>
                    </td>
                    <td>{$vo.desc}</td>
                    <td>{if condition="$vo.status=='1'"}使用中{else/}已停用{/if}</td>
                    <td>
                        <a class="rha-bt-a" href="javascript:;" onclick="editReply('{$vo.id}')">修改</a>
                        {if condition="$vo.status=='1'"}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','0')">停用</a>
                        {else/}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','1')">开启</a>
                        {/if}
                        <a class="rha-bt-a" href="javascript:;" onclick="delReply('{$vo.id}')">删除</a>

                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>

            {/case}

            {case value="voice"}
            <table class="layui-table" lay-skin="line">
                <col width="">
                <col width="">
                <col width="">
                <col width="" >
                <col width="100">
                <col width="150">
                <thead>
                <tr>
                    <th>关键词</th>
                    <th>类型</th>
                    <th>语音名称</th>
                    <th>语音资源|媒体ID</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.keyword}</td>
                    <td>{if condition="$vo.status_type eq '1'"} 永久
                        {elseif condition="$vo.status_type eq '0'"/}临时
                        {/if}</td>
                    <td>{$vo.title}</td>
                    <td><a href="__PUBLIC__/uploads/addkey/{$vo.url}" target="_blank">{$vo.url}</a></td>
                    <td>{if condition="$vo.status=='1'"}使用中{else/}已停用{/if}</td>
                    <td>
                        <a class="rha-bt-a" href="javascript:;" onclick="editReply('{$vo.id}')">修改</a>
                        {if condition="$vo.status=='1'"}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','0')">停用</a>
                        {else/}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','1')">开启</a>
                        {/if}
                        <a class="rha-bt-a" href="javascript:;" onclick="delReply('{$vo.id}')">删除</a>

                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {case value="image"}
            <table class="layui-table" lay-skin="line">
                <col width="">
                <col width="100">
                <col width="" >
                <col width="100">
                <col width="150">
                <thead>
                <tr>
                    <th>关键词</th>
                    <th>类型</th>
                    <th>封面图</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.keyword}</td>
                    <td>{if condition="$vo.status_type eq '1'"} 永久
                        {elseif condition="$vo.status_type eq '0'"/}临时
                        {/if}</td>
                    <td>
                        <div  style="padding: 5px; border: #e6e6e6 solid 1px; width:160px; float: left; ">
                            <img class="form_logo" src="__PUBLIC__/uploads/addkey/{$vo.url}" style="max-width: none" width="160" height="100">
                        </div>
                    </td>

                    <td>{if condition="$vo.status=='1'"}使用中{else/}已停用{/if}</td>
                    <td>
                        <a class="rha-bt-a" href="javascript:;" onclick="editReply('{$vo.id}')">修改</a>
                        {if condition="$vo.status=='1'"}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','0')">停用</a>
                        {else/}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','1')">开启</a>
                        {/if}
                        <a class="rha-bt-a" href="javascript:;" onclick="delReply('{$vo.id}')">删除</a>

                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {case value="video"}
            <table class="layui-table" lay-skin="line">
                <col width="">
                <col width="100">
                <col width="" >
                <col width="" >
                <col width="100">
                <col width="150">
                <thead>
                <tr>
                    <th>关键词</th>
                    <th>类型</th>
                    <th>视频标题|媒体ID</th>
                    <th>视频地址</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.keyword}</td>
                    <td>{if condition="$vo.status_type eq '1'"} 永久
                        {elseif condition="$vo.status_type eq '0'"/}临时
                        {/if}</td>
                    <td>
                        {$vo.title}
                    </td>
                    <td>
                       <a href="__PUBLIC__/uploads/addkey/{$vo.url}" target="_blank">{$vo.url}</a>
                    </td>
                    <td>{if condition="$vo.status=='1'"}使用中{else/}已停用{/if}</td>
                    <td>
                        <a class="rha-bt-a" href="javascript:;" onclick="editReply('{$vo.id}')">修改</a>
                        {if condition="$vo.status=='1'"}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','0')">停用</a>
                        {else/}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','1')">开启</a>
                        {/if}
                        <a class="rha-bt-a" href="javascript:;" onclick="delReply('{$vo.id}')">删除</a>

                    </td>

                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {case value="music"}
            <table class="layui-table" lay-skin="line">
                <col width="80">
                <col width="100">
                <col width="" >
                <col width="" >
                <col width="100">
                <col width="150">
                <thead>
                <tr>
                    <th>关键词</th>
                    <th>音乐标题</th>
                    <th>链接地址</th>
                    <th>音乐描述</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.keyword}</td>
                    <td>{$vo.title}</td>
                    <td>
                        <a href="__PUBLIC__/uploads/addkey/{$vo.url}" target="_blank">{$vo.url}</a>

                    </td>
                    <td>{$vo.content}</td>
                    <td>{if condition="$vo.status=='1'"}使用中{else/}已停用{/if}</td>
                    <td>
                        <a class="rha-bt-a" href="javascript:;" onclick="editReply('{$vo.id}')">修改</a>
                        {if condition="$vo.status=='1'"}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','0')">停用</a>
                        {else/}
                        <a class="rha-bt-a" href="javascript:;" onclick="updateReply('{$vo.id}','1')">开启</a>
                        {/if}
                        <a class="rha-bt-a" href="javascript:;" onclick="delReply('{$vo.id}')">删除</a>

                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {/switch}
        </div>
    </div>

</div>

<script>
    function delReply(id) {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.confirm('你确定需要删除吗？', {
                btn: ['是','不'] //按钮
            }, function(){
                $.post("{:url('delRule')}",{'id':id},function (res) {
                    if(res.status==1){
                        layer.alert(res.msg,function (index) {
                            window.location.reload();
                            layer.close(index);
                        })

                    }else{
                        layer.alert(res.msg)
                    }
                })
            }, function(){

            });
        });

    }
    function updateReply(id,status) {
        layui.use('layer', function(){
            var layer = layui.layer;
            $.post("{:url('updateRule')}",{'id':id,'status':status},function (res) {
                if(res.status==1){
                    layer.msg(res.msg,{icon:1,time:2000},function (index) {
                        window.location.reload();

                    })

                }else{
                    layer.alert(res.msg)
                }
            })
        });
    }
    var layer;
    layui.use('layer', function(){
        var layer = layui.layer;
    });
    function editReply(id) {
        layer.open({
            type: 2,
            title: '修改回复内容',
            shadeClose: true,
            shade: 0.5,
            area: ['680px', '550px'],
            content: '{:url("editautoreply")}?id='+id,
            cancel: function(index, layero){
                window.location.reload();
            }
        });
    }

</script>
{/block}